package main

import (
	"fmt"
	"strconv"
)

type Flags uint

const (
	FlagUp           Flags = 2 + iota // is up
	FlagBroadcast                     // supports broadcast access capability
	FlagLoopback                      // is a loopback interface
	FlagPointToPoint                  // belongs to a point-to-point link
	FlagMulticast                     // supports multicast access capability
)

func main() {
	s := "hello, world"
	fmt.Println(len(s))     // "12"
	fmt.Println(s[0], s[7]) // "104 119" ('h' and 'w')
	fmt.Printf("%d %[1]c\n", s[0])

	fmt.Println(s[:5]) // "hello"
	fmt.Println(s[7:]) // "world"
	fmt.Println(s[:])  // "hello, world"
	s = "78910"

	fmt.Printf("%c\n", s[1])
	fmt.Printf("%c\a\n", s[1])
	fmt.Printf("%c\b\n", s[1])
	fmt.Printf("%c\f\n", s[1])
	fmt.Printf("%c\r\n", s[1])
	fmt.Printf("%c\t\n", s[1])
	fmt.Printf("%c\v\n", s[1])
	fmt.Printf("%c\n", `试试这个不转\n义的
	
	
	字符串`)
	fmt.Printf("%c\n", "试试这个不转义\n的字符串")

	for i, r := range "Hello, 世界" {
		fmt.Printf("%d\t%q\t%d\t%d\n", i, r, r, r)
	}

	s1 := "プログラム"
	fmt.Printf("%x \n", s1) // "e3 83 97 e3 83 ad e3 82 b0 e3 83 a9 e3 83 a0"
	r := []rune(s1)
	fmt.Printf("%x\n", r) // "[30d7 30ed 30b0 30e9 30e0]"
	fmt.Println(string(r))
	fmt.Println(r)
	fmt.Println(string(0x4eac))

	x := 6666
	x2 := "test"
	fmt.Println(strconv.Itoa(x) + x2)
	x3 := fmt.Sprintf("%d", x)
	fmt.Println(x3 + x2)
	int123, _ := strconv.Atoi("123")
	fmt.Println(int123 + 1)
	fmt.Println(strconv.ParseInt("123", 10, 64))
	fmt.Println(FlagUp, FlagBroadcast, FlagLoopback, FlagPointToPoint, FlagMulticast)
}
